package com.android.hedgehog;

import android.graphics.Color;
import com.android.hedgehog.framework.Graphics;
public class SampleGameScreen extends GameScreen {

	public enum GameState {
		Ready, Running
	}

	Graphics graphics;
	SampleGameBox box1;
	SampleGameBox box2;
	SampleGameBox box3;
	SampleGameBox box4;
	GameState state;
	int level;

	public SampleGameScreen(Graphics graphics, int difficulty, double time) {
		this.graphics = graphics;
		state = GameState.Ready;
		box1 = new SampleGameBox(difficulty);
		box2 = new SampleGameBox(difficulty);
		box3 = new SampleGameBox(difficulty);
		box4 = new SampleGameBox(difficulty);
	}

	public int update(int X, int Y, int totalScore, double time) {
		if (state == GameState.Ready && time > 2) {
			state = GameState.Running;
		}

		if (state == GameState.Running) {
			if (X > 60 && X < (box1.width + 60) && Y > 100
					&& Y < (box1.height + 100)) {
				totalScore += box1.getPoints();
				gameOver = true;
			}
			if (X > 200 && X < (box2.width + 200) && Y > 100
					&& Y < (box2.height + 100)) {
				totalScore += box2.getPoints();
				gameOver = true;
			}
			if (X > 60 && X < (box3.width + 60) && Y > 300
					&& Y < (box3.height + 300)) {
				totalScore += box3.getPoints();
				gameOver = true;
			}
			if (X > 200 && X < (box4.width + 200) && Y > 300
					&& Y < (box4.height + 300)) {
				totalScore += box4.getPoints();
				gameOver = true;
			}
		}
		return totalScore;
	}

	public void present() {
		if (state == GameState.Ready) {
			graphics.drawPixmap(Assets.samplegamebox, 110, 350);
			graphics.drawText("Touch the larger boxes to score more points",
					150, 240, 14, Color.WHITE);
		}
		if (state == GameState.Running) {
			graphics.drawRect(60, 100, box1.width, box1.height, Color.BLUE);
			graphics.drawRect(200, 100, box2.width, box2.height, Color.RED);
			graphics.drawRect(60, 300, box3.width, box3.height, Color.YELLOW);
			graphics.drawRect(200, 300, box4.width, box4.height, Color.GREEN);
		}
	}

}
